package xworker.gluon.attach.browser;

import com.gluonhq.attach.browser.BrowserService;
import org.xmeta.ActionContext;
import org.xmeta.Thing;

import java.io.IOException;
import java.net.URISyntaxException;

public class BrowserActions {
    public static void launchExternalBrowser(ActionContext actionContext) throws IOException, URISyntaxException {
        Thing self = actionContext.getObject("self");
        String url = self.doAction("getUrl", actionContext);

        BrowserService service = BrowserService.create().orElse(null);
        if(service != null){
            service.launchExternalBrowser(url);
        }
    }
}
